package com.tim.spring.aop.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

@Aspect()
public class TestAspect {

	@Pointcut("execution (* *.display())")
	public void pointCut() {
		System.out.println("This is in TestAspect.pointCut");
	}

	@Before("execution (* *.display())")
	public void before() {
		System.out.println("This is in TestAspect.before");
	}

	@AfterReturning("execution (* *.display())")
	public void afterReturning() {
		System.out.println("This is in TestAspect.afterReturning");
	}

	@After("execution (* *.display())")
	public void after() {
		System.out.println("This is in TestAspect.after");
	}

	@Around("execution (* *.display())")
	public void around(ProceedingJoinPoint pjp) {
		System.out.println("这里是环绕通知的开始，下面手动调用方法了");
		System.out.println("Class: " + pjp.getTarget().getClass());
		System.out.println("Method: " + pjp.getSignature().getName());
		Object[] args = pjp.getArgs();
		if (args != null) {
			StringBuilder argSgring = new StringBuilder();
			for (int i = 0; i < args.length; i++) {
				
			}
		}
		System.out.println("");
		System.out.println("这里是环绕通知的结束，结束了。。。。");
	}
}
